/**
 * 
 */
package kr.co.insoft.auth.model.members.validator;

import kr.co.insoft.auth.model.members.TermsFormModel;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

/**
 * @author IN-SOFT Inc. GoodwillDD(sylee@in-soft.co.kr)
 *
 */
@Component
public class TermsFormValidator implements Validator {
	
	/* (non-Javadoc)
	 * @see org.springframework.validation.Validator#supports(java.lang.Class)
	 */
	@Override
	public boolean supports(Class<?> clazz) {
		return TermsFormModel.class.equals(clazz);
	}

	/* (non-Javadoc)
	 * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
	 */
	@Override
	public void validate(Object target, Errors errors) {
		TermsFormModel termsForm = (TermsFormModel)target;
		if ( !termsForm.isTerms1() )
			errors.rejectValue("terms1", "member.join.terms.agree.notcheck");
		if ( !termsForm.isTerms2() )
			errors.rejectValue("terms2", "member.join.terms.agree.notcheck");
	}

}
